package com.banzhi.shop.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.banzhi.shop.R;
import com.banzhi.shop.adapter.InnerFragmentPagerAdapter;
import com.banzhi.shop.adapter.MyCollegeAdapter;
import com.banzhi.shop.base.BaseActivity;
import com.banzhi.shop.fragment.Shouyi_DaifaFragment;
import com.banzhi.shop.fragment.Shouyi_YifaFragment;
import com.banzhi.shop.utils.Translucent;
import com.banzhi.shop.view.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

/**
 * 收益记录
 */
public class ShouyiJIluActivity extends BaseActivity implements View.OnClickListener {
    /**
     * 退出
     */
    private ImageView ivback;

    private TextView tvdaifa;

    private TextView tvyifa;
    private NoScrollViewPager viewPager;

/*    private TabLayout tabs;
    private ViewPager viewPager;
    private List<String> mTitle = new ArrayList<String>();
    private List<Fragment> mFragment = new ArrayList<Fragment>();
    private ImageView IvBackCollege;
    private TabLayout TabsCollege;
    private ViewPager VpCollege;

    private TextView TvShop;
    private TextView TvCollege;*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shouyi_jilu);
        Translucent.setTranslucent(this);
        setinits();
        setlisteners();
    }

    private void setinits() {
        ivback = (ImageView) findViewById(R.id.iv_back);
        tvdaifa = (TextView) findViewById(R.id.tv_daifa);
        tvyifa = (TextView) findViewById(R.id.tv_yifa);
        viewPager = (NoScrollViewPager) findViewById(R.id.viewpager);

        List<Fragment> fras = new ArrayList<>();
        fras.add(new Shouyi_DaifaFragment());
        fras.add(new Shouyi_YifaFragment());
        InnerFragmentPagerAdapter viewPagerAdapter = new InnerFragmentPagerAdapter(getSupportFragmentManager(), fras);
        viewPager.setAdapter(viewPagerAdapter);
    }

    private void setlisteners() {
        ivback.setOnClickListener(this);
        tvdaifa.setOnClickListener(this);
        tvyifa.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_daifa:
                tvyifa.setBackgroundResource(R.mipmap.bg2);
                tvyifa.setTextColor(Color.WHITE);
                viewPager.setCurrentItem(0, false);
                tvdaifa.setBackgroundResource(R.mipmap.bg1);
                tvdaifa.setTextColor(ContextCompat.getColor(this, R.color.themeColor));
                break;
            case R.id.tv_yifa:
                tvyifa.setBackgroundResource(R.mipmap.bg5);
                tvyifa.setTextColor(ContextCompat.getColor(this, R.color.themeColor));
                viewPager.setCurrentItem(1, false);
                tvdaifa.setBackgroundResource(R.mipmap.bg4);
                tvdaifa.setTextColor(Color.WHITE);
                break;
        }
    }
}
